function [a,P] = PassOrWait(P,S,mode)
    global num_players_r;
    global num_players_b;

    if(P{2} == 'r')
        num_players = num_players_r;
    else
        num_players = num_players_b;
    end
    
    P_num = P{3};
    
    if(P_num == num_players -1)
        k = num_players;
    else
        k = mod(P_num + 1, num_players);
    end
        
    if(PlayerInPossession(P,S,mode))
        [a,P] = PassBall(P,S,mode,k);
    elseif (~TeamInPossession(P,S,mode)) % if this player is closer to theball, go for it
        
        if(IsClosest(P,S,mode))
            [a, P] = GoToBall(P,S,mode);
        else
            a = '';
        end
    else
        a = '';
    end
end